<?php
	require_once("conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Formulario PSMB</title>
<link href="Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<link href="Estilos/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

<script src="include_js/jquery.js" type="text/javascript"></script>

<link href="calendario/calendar-win2k-cold-1.css" rel="stylesheet" type="text/css" />
<script src="calendario/calendar.js" type="text/javascript"></script>
<script src="calendario/calendar-es.js" type="text/javascript"></script>
<script src="calendario/calendar-setup.js" type="text/javascript"></script>

<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
</style>
<script>
function BorraDatos(dato)
{
	var cadena = dato.substring(8,9);
    if(cadena=='1')
	{
		document.getElementById("txtNum").value= "";
		document.getElementById('txtMonto').value = "";
		document.getElementById('cmb_Banco').value=0;		
		document.getElementById('txtFIni').value= "";		
		Foco();
	}
}

function EliminaPuntos(num)
{
	valor = num.replace(/\./g,'');
	return valor;
}

function validar(e)
{ 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\d/;
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
} 

function puntitos(donde,caracter)
{
	pat = /[\*,\+,\(,\),\?,\,$,\[,\],\^]/;
	valor = donde.value;
	largo = valor.length;
	crtr = true;
	if(isNaN(caracter) || pat.test(caracter) == true)
	{
		if (pat.test(caracter)==true)
		{ 
			caracter = "\"" + caracter;
		}
		carcter = new RegExp(caracter,"g");
		valor = valor.replace(carcter,"");
		donde.value = valor;
		crtr = false;
	}
	else
	{
		var nums = new Array();
		cont = 0;
		for(m=0;m<largo;m++)
		{
			if(valor.charAt(m) == "." || valor.charAt(m) == " ")
				{continue;}
			else
			{
				nums[cont] = valor.charAt(m);
				cont++;
			}
		}
	}
	var cad1="",cad2="",tres=0;
	if(largo > 3 && crtr == true)
	{
		for (k=nums.length-1;k>=0;k--)
		{
			cad1 = nums[k];
			cad2 = cad1 + cad2;
			tres++;
			if((tres%3) == 0)
			{
				if(k!=0)
				{
					cad2 = "." + cad2;
				}
			}
		}
		donde.value = cad2;
	}
}

function Foco()
{
	document.getElementById('txtNum').focus();
}
</script>
</head>
<body onload="Foco();">
<form name="form_Honorario" id="form_Honorario" method="post">
<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Secci&oacute;n Cheques.</label></div>
<div class='groupbox'>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno">
<tr>
  <td class="borde" colspan="2"><div style="float:left; clear:none; margin-left:10px; margin-top:5px;"><label style="color:#0000FF; font-size:12px; font-weight:bold;">Datos Obligatorios(*)</label></div></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" colspan="4"><hr /></td>
</tr>
<tr>
  <td class="borde" colspan="2"><label class="texto" style="font-weight:bold;">Datos del Cheque.</label></td>
  <td width="7%" class="borde">&nbsp;</td>
  <td width="35%" class="borde">&nbsp;</td>
  </tr>
<tr>
  <td width="22%" class="borde">&nbsp;</td>
  <td width="36%" class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
	<td class="borde"><label class="texto" style="margin-left:35px;">N&deg; Cheque:</label>&nbsp;</td>
	<td class="borde"><input type="text" name="txtNum" onkeypress="return validar(event)"/>&nbsp;<label class="asterisco">*</label></td>
	<td class="borde">&nbsp;</td>
	<td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde"><label class="texto" style="margin-left:35px;">Monto Pagar ($):</label></td>
  <td class="borde"><input type="text" name="txtMonto" onkeyup="puntitos(this,this.value.charAt(this.value.length-1))"/>&nbsp;<label class="asterisco">*</label></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde"><label class="texto" style="margin-left:35px;">Banco:</label></td>
  <td class="borde"><select name="cmb_Banco" id="cmb_Banco">
    <option value="0">--BANCO--</option>
    <?php
			$con = new Conexion();
    		$con2 = $con->conexionBD("fpproduccion");
			$sql = "select BancoCod,BancoNombre from banco";
			$resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			while ($row = mysql_fetch_row($resultado))
			{
				echo "<option value='".$row[0]."'>".$row[1]."</option>";
			}
            $con->cerrarBD();
		?>
  </select>&nbsp;<label class="asterisco">*</label></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
  <tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">Fecha Pago:</label></td>
	  <td class="borde" colspan="3"><input name="txtFIni" type="text" id="txtFIni" size="10">&nbsp;<img src="imagen/img.gif" width="20" height="14" title="calendario" style="cursor: pointer; border: 1px solid green;" onmouseover="this.style.background='black';" onmouseout="this.style.background=''" onclick="popUpCalendar(txtFIni, form_Honorario.txtFIni, 'dd-mm-yyyy');" />&nbsp;<label class="asterisco">*</label></td></tr>
  <tr>
    <td class="borde" colspan="4">&nbsp;</td>
  </tr> 
  <tr>
    <td class="borde" colspan="4"><div class="formtail"><input name="btn_Guardar" id="btn_Guardar" type="button" value=" " class="guardar" /></div></td>
  </tr>
</table>
</div>
</form>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td><div id="mensaje"></div></td></tr>
</table>
</body>
<script>
$('#btn_Guardar').click(function() 
{ 
        $.ajax({
            type: 'POST',
            url: 'Contabilidad/Ingresa_Cheques.php',
            data: $('#form_Honorario').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
				BorraDatos(data);
            }
        })
});
</script>
</html>